//
//  MyHeaderView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/21.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "MyHeaderView.h"

@interface MyHeaderView (){
    GLGWImageView * headerImageView;
    GLGWButton * loginBut;
}
@end

@implementation MyHeaderView{

}

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = kColor_Rule_Yellow;
        //
        GLGWButton * setBut = [[GLGWButton alloc] initWithFrame:CGRectMake(KScreenWidth - kWidthProportion_In_iPhoneTriploid(50), kHeightProportion_In_iPhoneTriploid(45), kWidthProportion_In_iPhoneTriploid(40), kHeightProportion_In_iPhoneTriploid(40)) inSuperView:self];
        setBut.tag = 330;
        setBut.image_Name = @"icon_shezhi";
        [setBut addTarget:self action:@selector(headerButAction:) forControlEvents:UIControlEventTouchUpInside];
        //
        headerImageView = [[GLGWImageView alloc] initInSuperView:self];
        headerImageView.imageName = @"icon_touxiang_weishangchuan";
        [headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(kWidthProportion_In_iPhoneTriploid(25));
            make.bottom.equalTo(self.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(25));
            make.width.height.equalTo(@(kWidthProportion_In_iPhoneTriploid(70)));
        }];
//        headerImageView.backgroundColor = kRandomColor;
        headerImageView.layer.cornerRadius = kWidthProportion_In_iPhoneTriploid(35);
        headerImageView.layer.masksToBounds = YES;
        //
        loginBut = [[GLGWButton alloc] initWithTitle:@"登录/注册" titleLableFont:SYSTEMFONT(14) titleLableColor:[UIColor whiteColor] inSuperView:self];
        [loginBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self->headerImageView);
            make.left.equalTo(self->headerImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(50)));
        }];
        loginBut.titleLabel.numberOfLines = 0;
        loginBut.title = @"186***17000001\n未认证";
        loginBut.tag =331;
        [loginBut addTarget:self action:@selector(headerButAction:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return self;
}

-(void)headerButAction:(GLGWButton *)sender{
    if (self.Block_HeaderAcyion) {
        self.Block_HeaderAcyion(sender);
    }
}

-(void)setInfor_model:(LoginModel *)infor_model{
    _infor_model = infor_model;
//    NSString *numberString = [_infor_model.data. stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
    [headerImageView sd_setImageWithURL:[NSURL URLWithString:_infor_model.data.avatar] placeholderImage:[UIImage imageNamed:@"icon_touxiang_weishangchuan"]];
    
}

@end
